package com.panda.admin.login.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.panda.admin.base.BaseEnum;
import org.apache.ibatis.reflection.MetaObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * author: tcy
 * description: 自动填充数据
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    private static final Logger log = LoggerFactory.getLogger(MyMetaObjectHandler.class);


    public void insertFill(MetaObject metaObject) {

        log.info("start insert fill....");

        this.setFieldValByName("commonStatus", BaseEnum.NORMAL.getValue(), metaObject);

        this.setFieldValByName("createTime", new Date(), metaObject);

    }


    public void updateFill(MetaObject metaObject) {

        log.info("start update fill....");

        this.setFieldValByName("updateTime", new Date(), metaObject);
    }

}
